package com.smyhvae.viewpagerdemo.viewpager.viewpager;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

import static android.content.ContentValues.TAG;

/**
 * @author Lin·俊浩
 * @since 2017/9/29
 */

public class ViewPagerAdapter extends PagerAdapter{

    private List<View> mViewList;

    public ViewPagerAdapter(List<View> mViewList){
        this.mViewList = mViewList;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position){
        container.addView(mViewList.get(position));
        return mViewList.get(position);
    }

    @Override
    public int getCount() {
        return mViewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object){
        container.removeView(mViewList.get(position));
    }
}
